package com.cyzy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyzy.mapper.AttendMapper;
import com.cyzy.pojo.Attend;
import com.cyzy.service.AttendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AttendServiceImpl extends ServiceImpl<AttendMapper, Attend> implements AttendService {
    @Autowired
    private AttendMapper attendMapper;


    @Override
    public List<Attend> myAttend(Attend attend) {
        LambdaQueryWrapper<Attend> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Attend::getStudentId, attend.getStudentId())
                .eq(Attend::getClassId,attend.getClassId())
                .orderByDesc(Attend::getAttendDate)
                .last("limit 10");
        return attendMapper.selectList(queryWrapper);
    }
}
